package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TProjAchieveInfo;
import cn.com.headfree.mouldshow.dao.TProjAchieveInfoDao;
import cn.com.headfree.vo.simple.ProjAchieveInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tProjAchieveInfoDao")
public class TProjAchieveInfoDaoImpl extends BaseDaoImpl<TProjAchieveInfo> implements TProjAchieveInfoDao {


    @Override
    public List<ProjAchieveInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params=new Object[1];
//        StringBuilder sql=new StringBuilder("select t.id,t.start_date,DATE_FORMAT(t.start_date,'%Y-%m-%d %H:%i:%s') as start_date_str,t.end_date,DATE_FORMAT(t.end_date,'%Y-%m-%d %H:%i:%s') as end_date_str,t.proj_name,t.summary,GET_DIC('StandardLevel',t.proj_level) as proj_level,GET_DIC('XiangMuKeTiJS',p.role) as role,p.erp_no,u.xb_name as user_name,p.rank,t.encourage from t_proj_achieve_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on p.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.start_date,DATE_FORMAT(t.start_date,'%Y-%m-%d %H:%i:%s') as start_date_str,t.end_date,DATE_FORMAT(t.end_date,'%Y-%m-%d %H:%i:%s') as end_date_str,t.proj_name,t.summary,GET_DIC('StandardLevel',t.proj_level) as proj_level,GET_DIC('XiangMuKeTiJS',p.role) as role,p.erp_no,u.`NAME` as user_name,p.rank,t.encourage from t_proj_achieve_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.start_date,t.end_date,t.proj_name,t.summary,GET_DIC('StandardLevel',t.proj_level) as proj_level,GET_DIC('XiangMuKeTiJS',p.role) as role,p.erp_no,u.`NAME` as user_name,p.rank,t.encourage from t_proj_achieve_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
        StringBuilder sql=new StringBuilder("select t.id,t.start_date,t.end_date,t.proj_name,t.summary,t.proj_level,p.role,p.erp_no,u.`NAME` as user_name,p.rank,t.encourage from t_proj_achieve_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(ProjAchieveInfoVo.class, sql.toString(), null, false, params);
    }
}
